//
//  ViewController.m
//  LayOut布局
//
//  Created by mac on 16/7/18.
//  Copyright © 2016年 haha😄. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *label;
@property (weak, nonatomic) IBOutlet UIButton *button;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

//在视图控制器中纯代码布局，会调用该方法；
//只要尺寸发生变化的时候都会调用这个方法（从新计算所有控件布局的frame）
-(void)viewWillLayoutSubviews
{
    
    //label ;
    CGRect frame = CGRectZero;
    frame.origin = CGPointMake(20, 20);
    frame.size.width = (self.view.bounds.size.width-60)/2;
    frame.size.height = 40;
    self.label.frame = frame;
    
    
    //button;
    self.button.frame = CGRectMake(20+self.label.frame.size.width+20, 20, self.label.frame.size.width, 40);
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
